/******************************************************************************
 *  Copyright 2013 Bernhard Grünewaldt                                        *
 *                                                                            *
 *  Licensed under the Apache License, Version 2.0 (the "License");           *
 *  you may not use this file except in compliance with the License.          *
 *  You may obtain a copy of the License at                                   *
 *                                                                            *
 *      http://www.apache.org/licenses/LICENSE-2.0                            *
 *                                                                            *
 *  Unless required by applicable law or agreed to in writing, software       *
 *  distributed under the License is distributed on an "AS IS" BASIS,         *
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  *
 *  See the License for the specific language governing permissions and       *
 *  limitations under the License.                                            *
 ******************************************************************************/
package com.google.code.greenwood.confluencemavenreleaseinfomacro.pojo;

public abstract class BaseArtifactInformation {

	private String name;

	private String groupid;
	
	private String artifactid;
	
	private String version;

	private String packaging;
	
	
	public String getDownloadUrl(String baseUrlToMavenRepo) {
		if (baseUrlToMavenRepo == null  || baseUrlToMavenRepo.isEmpty()) {
			return null;
		}
		StringBuilder url = new StringBuilder();
		url.append(baseUrlToMavenRepo);
		if (!baseUrlToMavenRepo.endsWith("/")) {
			url.append("/");	
		}		
		groupid = groupid.replaceAll("\\.", "/");
		url.append(groupid);
		url.append("/");
		url.append(artifactid);
		url.append("/");
		url.append(version);
		url.append("/");
		url.append(artifactid);
		url.append("-");
		url.append(version);
		url.append(".");
		url.append(packaging);
		return url.toString();
	}	
	
	public String getSourceUrl(String baseUrlToMavenRepo) {
		if (baseUrlToMavenRepo == null  || baseUrlToMavenRepo.isEmpty()) {
			return null;
		}
		StringBuilder url = new StringBuilder();
		url.append(baseUrlToMavenRepo);
		if (!baseUrlToMavenRepo.endsWith("/")) {
			url.append("/");	
		}		
		groupid = groupid.replaceAll("\\.", "/");
		url.append(groupid);
		url.append("/");
		url.append(artifactid);
		url.append("/");
		url.append(version);
		url.append("/");

		return url.toString();
	}	

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getGroupid() {
		return groupid;
	}

	public void setGroupid(String groupid) {
		this.groupid = groupid;
	}

	public String getArtifactid() {
		return artifactid;
	}

	public void setArtifactid(String artifactid) {
		this.artifactid = artifactid;
	}

	public String getVersion() {
		return version;
	}

	public void setVersion(String version) {
		this.version = version;
	}

	public String getPackaging() {
		return packaging;
	}

	public void setPackaging(String packaging) {
		this.packaging = packaging;
	}	
	
}
